home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7078 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.9 KB

  1. Path: ilnews.iil.intel.com!pauls
  2. From: Michael Tiomkin <mtiomkin@iil.intel.com>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Why won't this compile????
  5. Date: 18 Feb 1996 11:43:31 GMT
  6. Organization: Intel Israel
  7. Message-ID: <4g73d3$1fk0@ilx018.iil.intel.com>
  8. References: <4g50et$9lh@steel.interlog.com>
  9. NNTP-Posting-Host: ilnt169.iil.intel.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 1.22 (Windows; I; 32bit)
  14.  
  15.   your program isn't exactly ANSI C: in the last printf, its 
  16. 1st argument, intended to be a char string, doesn't end with a 
  17. double quote.  This makes the compiler understand the code in 
  18. a different way.
  19.  
  20.    Good luck!
  21.  
  22.  Michael
  23.  
  24. kingkaos@interlog.com (King Kaos) wrote:
  25. >
  26. >    Hi.  Can someone please explain why this program won't
  27. >compile without errors?  I am using Power C under DOS.
  28. >
  29. >
  30. >Heres the ANSI-C code:
  31. >
  32. >#include <stdio.h>
  33. >#include <stdlib.h>
  34. >
  35. >void swap(int *, int *);
  36. >
  37. >main()
  38. >{
  39. >    int var1, var2;
  40. >
  41. >    var1 = 25;
  42. >    var2 = 99;
  43. >    printf("Variables before swap");
  44. >    printf("var1 = %d , var2 = %d\n",var1,var2);
  45. >
  46. >    swap(&var1, &var2);
  47. >    printf("Variables after swap");
  48. >    printf("var1 = %d , var2 = %d\n,var1,var2);  /* !! */
  49. >}
  50. >
  51. >void swap(int *ptr1,int *ptr2)
  52. >{
  53. >    int temp;
  54. >    temp = *ptr1;
  55. >    *ptr1 = *ptr2;
  56. >    *ptr2 = temp;
  57. >}
  58. >
  59. >-----------------------------
  60. >And, heres the C.ERR file:
  61. >
  62. >pointc~1.txt(18):}
  63. >****************                ^202
  64. >      202: String constant cannot span lines
  65. >------------------------------------------------------------
  66. >pointc~1.txt(20):void swap(int *ptr1,int *ptr2)
  67. >**************** ^  4, 14           ^  6    ^104,222,  6,104,222
  68. >        4: ')' expected
  69. >       14: ';' expected
  70. >        6: Illegal symbol
  71. >      104: Undeclared identifier
  72. >      222: Warning - Pointer does not match scalar (int, long, etc)
  73. >------------------------------------------------------------
  74. >pointc~1.txt(21):{
  75. >**************** ^ 14
  76. >       14: ';' expected
  77. >------------------------------------------------------------
  78. >pointc~1.txt(23):        temp = *ptr1;
  79. >****************                     ^104,141
  80. >      104: Undeclared identifier
  81. >      141: Type of variable is not pointer
  82. >------------------------------------------------------------
  83. >pointc~1.txt(24):        *ptr1 = *ptr2;
  84. >****************              ^104,141,104,141
  85. >      104: Undeclared identifier
  86. >      141: Type of variable is not pointer
  87. >------------------------------------------------------------
  88. >pointc~1.txt(25):        *ptr2 = temp;
  89. >****************              ^104,141
  90. >      104: Undeclared identifier
  91. >      141: Type of variable is not pointer
  92. >------------------------------------------------------------
  93. >pointc~1.txt(26):}
  94. >****************  ^  9
  95. >        9: Right braces expected
  96. >------------------------------------------------------------
  97. >
  98. >
  99. >Any help will be appericated.  Please email respones directly to
  100. >me.  Thank's.
  101. >
  102. >
  103. >
  104. >        KING KAOS
  105. >
  106.  
  107.  
  108.